-
Notifications
You must be signed in to change notification settings - Fork 30
feat: example using hwi signing with #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Thanks for this! looks like a good simple example for using |
So I think after constructing the psbt we can just call that function and voila. |
|
||
let _ = bb.register_wallet("test-wallet", descriptor).await.unwrap(); | ||
|
||
let bitbox_signer = HwiSigner::new(bb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So at this level we can just call bibox_signer.sign(psbt)
given that the psbt has been constructed with bdk_wallet
or something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think this is the right approach. Even though it makes the example much simpler it's still useful to show the end-to-end flow of using async-hwi
to sign a psbt created with bdk_wallet::TxBuilder
(and eventually the bdk_tx::TxBuilder
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea to add syncing wallet code in the example?
If not what's a good way of mocking the wallet with some utxos to sign?
@notmandatory I also added a feature Please let me know what you think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this one, I left a few comments and also would recommend squashing the commits into a single one and follow the https://www.conventionalcommits.org/en/v1.0.0/ (e.g chore(example): add example using `async-hwi`
.
Thanks for taking a look @oleonardolima. I've addressed your suggestions. |
Thanks for the updates, I'll do a round of review and testing. |
I recommend a rebase for this after the |
@sdmg15 You need to rebase to get latest updates and API changes from 2.0 release. I'm reviewing/testing it and it doesn't seem to work, as it's currently implemented the simulator/hw device it's not using the same wallet/descriptors, it should probably be imported in order to sign the PSBT tx by created by BDK wallet. |
Thanks for taking time for reviewing @oleonardolima The simulator uses the following mnemonic (quoting the bitbox code):
The extended private key that I have in the code is: When you say it's not working do you encounter any error? In non-simulator bdk wallet seems to still be using the descriptor of simulator which is one the thing to fix i think :) |
Updated the code to follow the new API and run another round of tests in simulator mode and everything seems ok. Let me know the issues you're running into @oleonardolima |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @sdmg15 for working on this.
I have setup the bitbox simulator but it doesn't seem to connect and when I run the example with the simulator
feature enabled, the version of bitbox API do breaks (shared in the comments).
The simulator runs on a docker container and exposes port 15423

Can you check if it is my setup that is not correct or you need to update the bitbox-api version?
Thank you.
[dependencies] | ||
bdk_wallet = { path = "../../wallet", features = ["file_store"] } | ||
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] } | ||
bitbox-api = {version = "0.6.0", features = ["tokio"], optional = true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version of bitbox-api
seems to be throwing errors at my end:
error[E0053]: method `read` has an incompatible type for trait
--> /Users/vihigatyonum/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bitbox-api-0.6.0/src/simulator.rs:45:1
|
45 | #[async_trait(?Send)]
| ^^^^^^^^^^^^^^^^^^^^^ expected trait `std::future::Future<Output = Result<Vec<u8>, communication::Error>> + Send`, found trait `std::future::Future<Output = Result<Vec<u8>, communication::Error>>`
|
Maybe you can consider updating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @sdmg15 for responding. I have the same version, but I guess there is a mix-up somewhere that I need to figure out.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on this issue on bdk-cli, when I am done, you might help review the PR. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright no issue, we could sync up in a call if you want so that we can figure what's going on, I'm in the bdk discord @sdmg15 is my handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I will reach out. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same version, but I guess there is a mix-up somewhere that I need to figure out.
After our conversation and applying the bitbox-api
v0.6.0 patch, it worked; however, async-hwi
's latest version (0.0.28) still points to v0.6.0 of bitbox-api
. So, a better approach might be to use only async-hwi
, as it offers support for other hardware devices, not just bitbox
.
Thank you
Description
Integrates a new BDK signer using async-hwi.
The included example uses Bitbox02 but can be easily extended to use any other supported device.
Notes for reviewer
It's related to issue #20
Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing